﻿using Model;
using Smobiler.Core;
using Smobiler.Core.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FubiManger.UI;

namespace FubiManger.Controls
{
    ////ToolboxItem用于控制是否添加自定义控件到工具箱，true添加，false不添加
    //[System.ComponentModel.ToolboxItem(true)]
    partial class Carproductcontrol : Smobiler.Core.Controls.MobileUserControl
    {
        public Carproductcontrol() : base()
        {
            //This call is required by the SmobilerUserControl.
            InitializeComponent();
        }
        /// <summary>
        /// 商品名称
        /// </summary>
        public string proname { get; set; }
        /// <summary>
        /// 商品封面
        /// </summary>
        public string proimg { get; set; }
        /// <summary>
        /// 价格
        /// </summary>
        public double price { get; set; }
        /// <summary>
        /// 数量
        /// </summary>
        public int count { get; set; }
        /// <summary>
        /// 商品ID
        /// </summary>
        public int proid { get; set; }
        private void btncut_Press(object sender, EventArgs e)
        {
            count--;
            try
            {
                if (count == 0)
                {
                    ((Buycarcontrol)this.Owner.Owner).Delpro(proid);//删除商品
                }

                else
                {
                    lblprice.Text = (price * count).ToString();
                    lblcount.Text = count.ToString();
                    Gdpro pro = new Gdpro();
                    pro.proname = proname;
                    pro.proimg = proimg;
                    pro.count = count;
                    pro.price = price;
                    ((OrderfoodForm)this.Form).Changebuycar(proid, pro);
                }
            }
            catch (Exception)
            {


            }
        }

        private void btnadd_Press(object sender, EventArgs e)
        {
            count++;
            lblprice.Text = (price * count).ToString();
            lblcount.Text = count.ToString();
            Gdpro pro = new Gdpro();
            pro.proname = proname;
            pro.proimg = proimg;
            pro.count = count;
            pro.price = price;
            ((OrderfoodForm)this.Form).Changebuycar(proid, pro);
        }

        private void Carproductcontrol_Load(object sender, EventArgs e)
        {
            lblcount.Text = count.ToString();
            lblname.Text = proname;//商品名称
            lblprice.Text = (price * count).ToString();//价格
            imgheard.ResourceID = @"C:\fbimage\" + proimg;//图片
        }
    }
}